package com.w.waiagent.controller.demo.invoke;

import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.model.chat.ChatModel;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * LangChain4j 调用 阿里云百联 平台模型 示例
 *
 * 官网示例:https://docs.langchain4j.dev/integrations/language-models/dashscope
 *
 * @author wzp
 * @since 2025/6/8
 */
@Slf4j
@RestController
@RequestMapping("/langchain4j/dashscope/")
public class LangChain4JDemo {
    private static final String DEFAULT_PROMPT = "你好，介绍下你自己！";
    @Value("${aliyunai.apiKey}")
    private String apiKey;

    @GetMapping("/simple/chat")
    public String simpleChat() {
        ChatModel qwenModel = QwenChatModel.builder()
                .apiKey(apiKey)
                .modelName("qwen-max")
                .build();

        return qwenModel.chat(DEFAULT_PROMPT);
    }
}
